import smtplib
from email.mime.text import MIMEText
from email.header import Header

mail_host_port = 465

# mail_host = 'smtp.exmail.qq.com'
# sender = 'luzhiyuan@zhenrongbao.com'
# mail_user = 'luzhiyuan@zhenrongbao.com'
# mail_pass = '4X698oAUhskcBnSp'

mail_host = 'smtp.qq.com'
sender = '409766661@qq.com'
mail_user = '409766661@qq.com'
mail_pass = 'uwgtawzxubtubgch'

receivers = ['fuxianxi@didiglobal.com']

# 邮件标题
context = '''
<html>
<h1>请从床上站起来</h1><br>
<img src="https://pic3.zhimg.com/80/v2-744a6e3da847417880e7f8401b8e2380_hd.jpg">
</html>
'''
message = MIMEText(context, 'html', 'utf-8')
# 发件人昵称
message['From'] = Header('亚洲唯一的王子', 'utf-8')
# 收件人昵称
message['To'] = Header('妖怪', 'utf-8')

# 邮件内容
subject = '[hello,world] 请从床上站起来'
message['Subject'] = Header(subject, 'utf-8')

try:
    # 通过SSL方式连接
    smtpObj = smtplib.SMTP_SSL(mail_host, mail_host_port)
    # 登录邮箱
    smtpObj.login(mail_user, mail_pass)
    # 发送邮件
    smtpObj.sendmail(sender, receivers, message.as_string())

    print('邮件发送成功')
except smtplib.SMTPException:
    print('Error: 无法发送邮件')
    raise
